<?php

namespace App\Http\Controllers\Admin\Ucenter;

use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Ucenter\User\LoginRequest;
use App\Http\Requests\Admin\Ucenter\User\UpdatePwdRequest;
use App\Logics\Admin\Ucenter\UserLogic;
use Illuminate\Http\Request;

/**
 *
 * @authors generator
 * @date    2020-11-06 18:40:47
 */
class UserController extends Controller
{
    protected $logic;

    public function __construct(UserLogic $logic)
    {
        $this->logic = $logic;
    }

    /**
     * 管理员登录 admin/ucenter/user/login
     *
     * @param  LoginRequest $request [description]
     * @return Response
     */
    public function login(LoginRequest $request)
    {
        $param = $request->params();  // params方法传入对应的Param对象

        $result = $this->logic->adminLogin($param, $request->ip());

        return ok($result);
    }

    /**
     * 管理员信息 admin/ucenter/user/info
     *
     * @param  Request $request [description]
     * @return Response
     */
    public function info(Request $request)
    {

        $result = $this->logic->adminInfo();

        return ok($result);
    }



    /**
     * 管理员修改密码 admin/ucenter/user/update-pwd
     *
     * @param  UpdatePwdRequest $request [description]
     * @return Response
     */
    public function updatePwd(UpdatePwdRequest $request)
    {
        $param = $request->params();  // params方法传入对应的Param对象

        $result = $this->logic->updatePwd($param);

        return ok($result);
    }

    /**
     * 管理员退出 admin/ucenter/user/logout
     *
     * @param  Request $request [description]
     * @return Response
     */
    public function logout(Request $request)
    {
        $result = $this->logic->logout();

        return ok($result);
    }

    /** #generate function# 删除后将无法自动生成控制器方法 */
}
